﻿using System;
using System.Collections.Generic;
using ProjScan.Submodules.Custom_Rules_Check;
using ProjScan.Tools;

namespace ProjScan.ScanRule.CustomRules
{
	// Token: 0x02000201 RID: 513
	public class ColumnInfo
	{
		// Token: 0x06000F11 RID: 3857 RVA: 0x000073C8 File Offset: 0x000055C8
		public ColumnInfo(string name)
		{
			this.Name = name;
			this.Data = new List<object>();
			this.Type = ColumnInfo.ColumnType.UNSET;
		}

		// Token: 0x06000F12 RID: 3858 RVA: 0x00043354 File Offset: 0x00041554
		public void AddData(object val)
		{
			bool flag = false;
			ColumnInfo.ColumnType columnType = ColumnInfo.CheckColumnType(val);
			bool flag2 = this.Type == ColumnInfo.ColumnType.UNSET;
			if (flag2)
			{
				this.Type = columnType;
			}
			else
			{
				bool flag3 = this.Type == ColumnInfo.ColumnType.INT && columnType == ColumnInfo.ColumnType.FLOAT;
				if (flag3)
				{
					this.Type = ColumnInfo.ColumnType.FLOAT;
				}
				else
				{
					bool flag4 = (this.Type != ColumnInfo.ColumnType.FLOAT || columnType != ColumnInfo.ColumnType.INT) && this.Type != columnType;
					if (flag4)
					{
						flag = true;
						string text = string.Format("添加的数据类型({0})与该列的类型({1})不匹配!", columnType, this.Type);
						bool flag5 = columnType == ColumnInfo.ColumnType.UNSET;
						if (flag5)
						{
							text += "（请检查添加的一行的参数数量是否少于表格的列数）";
						}
						Singleton<StackTraceLogger>.Instance.RecordStackTrace(text);
					}
				}
			}
			bool flag6 = columnType == ColumnInfo.ColumnType.STRING;
			if (flag6)
			{
				string text2 = val as string;
				bool flag7 = text2.Length > 256;
				if (flag7)
				{
					text2 = text2.Substring(0, 256);
					Singleton<StackTraceLogger>.Instance.RecordStackTrace("String参数长度过大，将只保留前256个字符。");
				}
			}
			bool flag8 = flag;
			if (flag8)
			{
				this.Data.Add(null);
			}
			else
			{
				this.Data.Add(val);
			}
		}

		// Token: 0x06000F13 RID: 3859 RVA: 0x00043480 File Offset: 0x00041680
		public static ColumnInfo.ColumnType CheckColumnType(object obj)
		{
			bool flag = obj != null;
			if (flag)
			{
				Type type = obj.GetType();
				bool isEnum = type.IsEnum;
				if (isEnum)
				{
					return ColumnInfo.ColumnType.INT;
				}
				bool flag2 = ColumnInfo._typeDict.ContainsKey(type);
				if (flag2)
				{
					return ColumnInfo._typeDict[type];
				}
			}
			return ColumnInfo.ColumnType.UNSET;
		}

		// Token: 0x040008DE RID: 2270
		private static Dictionary<Type, ColumnInfo.ColumnType> _typeDict = new Dictionary<Type, ColumnInfo.ColumnType>
		{
			{
				typeof(sbyte),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(byte),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(short),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(ushort),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(int),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(uint),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(long),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(ulong),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(char),
				ColumnInfo.ColumnType.INT
			},
			{
				typeof(float),
				ColumnInfo.ColumnType.FLOAT
			},
			{
				typeof(double),
				ColumnInfo.ColumnType.FLOAT
			},
			{
				typeof(decimal),
				ColumnInfo.ColumnType.FLOAT
			},
			{
				typeof(string),
				ColumnInfo.ColumnType.STRING
			},
			{
				typeof(bool),
				ColumnInfo.ColumnType.BOOL
			}
		};

		// Token: 0x040008DF RID: 2271
		public string Name = null;

		// Token: 0x040008E0 RID: 2272
		public ColumnInfo.ColumnType Type = ColumnInfo.ColumnType.UNSET;

		// Token: 0x040008E1 RID: 2273
		public List<object> Data = null;

		// Token: 0x02000202 RID: 514
		public enum ColumnType
		{
			// Token: 0x040008E3 RID: 2275
			INT,
			// Token: 0x040008E4 RID: 2276
			FLOAT,
			// Token: 0x040008E5 RID: 2277
			BOOL,
			// Token: 0x040008E6 RID: 2278
			STRING,
			// Token: 0x040008E7 RID: 2279
			UNSET
		}
	}
}
